package com.dudu.dao;

import java.sql.Connection;
import java.util.List;

import org.apache.log4j.Logger;

import core.CoreDao;
import core.db.DBConnectionUtil;
import net.sf.json.JSONObject;

/**
 * 卡密支付
 * @author zx
 *
 */
public class PayCardDao {
	
	public static  Logger logger = Logger.getLogger(PayCardDao.class);
	
	/**
	 * 通过appkey查询卡密支付相关信息
	 * @param dao
	 * @param app_key
	 * @return
	 */
	public JSONObject queryCardPayInfoByAppKey(CoreDao dao,String app_key){
		Connection con = null;
		JSONObject result = null;
		try {
			con = DBConnectionUtil.getDBConnection("emate1");			
			List<JSONObject> list = dao.serviceJsonSql(con, "select cp.company_code,cp.product_code,cp.region_code from t_app_cardpay cp where cp.app_key=?",new Object[]{app_key});			
			if (list != null && list.size() > 0) {	
				result = list.get(0);
			}

		} catch (Exception ex) {
			ex.printStackTrace();
		} finally {
			DBConnectionUtil.close(null, null, con);
		}
		return result;	
	}
}
